import sys


def in_asc_range_word(s, start, end):
    if start <= ord(s) <= end:
        return True
    return False


def has_same_son_str(_str):
    _set = set()
    for i in range(len(_str) - 2):
        prefix = _str[i:i + 3]
        if prefix in _set:
            return True
        else:
            _set.add(prefix)
    return False


def check(_str):
    if len(_str) <= 8:
        return False
    flag = [0] * 4
    # 无数字
    for s in _str:
        if in_asc_range_word(s, 48, 57):
            flag[0] = 1
        # 无大写
        elif in_asc_range_word(s, 65, 90):
            flag[1] = 1
        # 无小写
        elif in_asc_range_word(s, 97, 122):
            flag[2] = 1
        # 无特殊字符串
        elif any([in_asc_range_word(s, 33, 47),
                  in_asc_range_word(s, 58, 64),
                  in_asc_range_word(s, 123, 126)]):
            flag[3] = 1
    if sum(flag) < 3:
        return False
    if has_same_son_str(_str):
        return False
    return True


for line in sys.stdin:
# for line in [
#     "021Abc9000",
# "021Abc9Abc1",
# "021ABC9000",
# "021$bc9000",
# "021Abc1111",
# ]:
    if not check(line):
        print("NG")
    else:
        print("OK")
